import System;		// Needed for .Net which is needed to save a temp file
import System.IO;	// for the "Browser.SaveFile" demo.

var BrowsersParent : GameObject; // The gameObject that you place the "Browser.cs" in.
private var Browser : Object; // A refrence to the Browser you are trying to control, will be found automatically on Awake.

function Awake() // Runs once before Start, best used to get refrences to other scripts.
{
	Browser = BrowsersParent.GetComponent("Browser");
}

function OnGUI() // Runs once at Runtime when object is loaded.
{
	// To Open a file with the browser run:  Browser.OpenFile( The_Path_To_Your_MainSaves_Folder );
	// The following is an example that will open the root directory of your project. If you run this in
	// Unity, without compiling, then the file browser will be a duplicate of your "Project" tab.
	if(GUI.Button(Rect(5,5,230,30), "Test Browser's Open File function"))
	{
		Browser.OpenFile( Application.dataPath);
	}
	
	if(GUI.Button(Rect(5,50,230,30), "Test Browser's Save File function"))
	{		
			// All of this is just to create an example text file, if you want to know more about how I created it with System.IO and .Net 
			// feal free contact me with any questions on the forums (I know from experiance that there isn't exaclty much documentation 
			// on saving and loading files for beginers out there), or do what I did and comb through the .Net library's refrence on System.IO 
			// at:   http://msdn.microsoft.com/en-us/library/system.io.aspx
			var FileName = Application.dataPath + "/TempSaveFile";
			var Sw = new StreamWriter(FileName);
			Sw.WriteLine("This is an example save file.");
			Sw.WriteLine("");
			Sw.WriteLine("It was righten to show the ''Browser.SaveFile'' function in action.");
			Sw.WriteLine("...and apparently...");
			Sw.WriteLine("It works!!!");
			Sw.WriteLine("");
			Sw.WriteLine("YAY!!!!");
			Sw.Close();
		// This is the actual save file comand that you need to know about, the first:
		Browser.SaveFile( FileName, Application.dataPath+"/Demo Directory Tree");
	}
}